Skip to content

Conversation

@SynnekOG
Copy link

Summary

This PR introduces a comprehensive refactor of the arbitrage system, improving maintainability, standardizing naming conventions, and modernizing dependencies across contracts, scripts, and tests. The work consolidates the arbitrage contract under the new Arbitrage identifier, enhances compatibility with external libraries, and streamlines integration with Chainlink and Uniswap.


Changes

🔑 Core Contracts

  • FlashArbitrageV2.sol

    • Removed redundant SafeERC20 usage.
    • Replaced safeTransfer/safeApprove with direct transfer/approve for simplicity and consistency.
    • Added new EmergencyWithdrawal event for transparency when funds are withdrawn.
    • Improved comments and readability.
  • FlashArbitrageV3.sol

    • Removed SafeERC20 usage, switching to direct transfers.
    • Updated Chainlink import path to use @chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol for broader compatibility.
    • Introduced ArbitrageParamsV3 struct to encapsulate advanced execution parameters.
    • Extended statistics tracking with enhanced volatility and route failure tracking.
    • Added governance-like parameters: maxGasPrice, dynamicProfitMultiplier, and flexible profit sharing.
    • Replaced safeTransfer/safeApprove with transfer/approve consistently across profit distribution and swap logic.

🏗 Deployment & Scripts

  • DeployArbitrage.s.sol

    • Standardized contract naming: FlashArbitrageArbitrage.
    • Simplified setUp() variable naming (modeConfigSepoliaConfig).
    • Deployment now returns Arbitrage instance for clarity.
  • Swap.s.sol

    • Updated references to Arbitrage.
    • Fixed ERC20 import path to the modern OpenZeppelin convention (@openzeppelin/contracts).
  • PriceManipulation.s.sol

    • Migrated ERC20 imports to consistent OpenZeppelin namespace.

🧪 Tests

  • ArbitrageTest.t.sol

    • Updated test suite to use Arbitrage instead of FlashArbitrage.
    • Standardized contract instantiation and helper config usage.
  • PriceManipulationTest.t.sol

    • Updated OpenZeppelin ERC20 import path for consistency.

⚙️ Project Configuration

  • .gitmodules

    • Added chainlink-brownie-contracts as a new submodule dependency.
  • foundry.lock

    • Locked chainlink-brownie-contracts at 1.3.0.
  • foundry.toml

    • Updated remappings to include @chainlink/contracts.
  • .vscode/settings.json

    • Pinned Solidity remote version to v0.8.18+commit.87f61d96 for developer consistency.

Motivation

  • Consistency: Aligns all arbitrage-related components under a unified Arbitrage contract name.
  • Maintainability: Removes redundant SafeERC20 usage, simplifying the codebase while maintaining security.
  • Extensibility: Adds advanced execution parameters and governance variables in V3 for greater flexibility.
  • Compatibility: Updates import paths and dependency versions to align with modern OpenZeppelin and Chainlink standards.
  • Developer Experience: Improves local tooling and clarity in deployment scripts, tests, and configuration.

Next Steps

  • Add comprehensive unit and fork tests for new V3 features (profit sharing, gas limit enforcement, route tracking).
  • Benchmark gas efficiency of direct transfer vs SafeERC20 in practice.
  • Expand arbitrage strategies with multi-router and multi-DEX support.
  • Implement access controls for advanced features like maxGasPrice and dynamicProfitMultiplier.

@DianaRicee DianaRicee self-requested a review September 28, 2025 18:19
@DianaRicee DianaRicee added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 28, 2025
@DianaRicee DianaRicee merged commit dbcaa38 into FlashArb-AI:main Sep 28, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants